/**
 * 作者: wgx
 * 日期: 2024-10-12 10:46:36
 * 备注: 用户道具
 */
package com.motu.monstercity.server.game.userdata;

import com.motu.monstercity.server.game.log.MotuLogManager;
import io.vertx.core.json.JsonArray;

public class UserItem extends UserItemModel {
    public UserItem() {
        super();
    }

    public UserItem(long userId, int itemId, long num) {
        super();
        putUserId(userId);
        putItemId(itemId);
        putNum(num);
    }

    public void addNum(UserInfo userInfo, long value, Object... logParams) {
        super.addNum(value);
        update();
        // 记录消耗获得日志
        MotuLogManager.logItemIncome(userInfo, getItemId(), getId(), getNum() - value, value, logParams);
    }

    public void subdNum(UserInfo userInfo, long value, Object... logParams) {
        if (value < 1) {
            return;
        }
        super.addNum(-value);
        update();
        // 记录消耗获得日志
        MotuLogManager.logItemConsume(userInfo, getItemId(), getId(), getNum() + value, value, logParams);
    }
}
